package com.example.exception;


import com.example.spzx.model.vo.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
  //统一异常处理类
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        System.out.println(e+"e");

        e.printStackTrace();
        return Result.build(null,201,"异常");

    }
    @ExceptionHandler(OmegaException.class)
    @ResponseBody
    public Result error(OmegaException exception) {
        System.out.println("异常捕获");
        exception.printStackTrace();
        return Result.build(null , exception.getResultCodeEnum()) ;
    }
}
